/*Shift-JIS*/
/*UTF-8*/
/********************************************************************************/
/*ソース名:                                                                     */
/*    alert.c                                                                   */
/*機能:                                                                         */
/*     エラーメッセージの作成・出力                                             */
/*作成者:                                                                       */
/*    2010/06 関（CBSﾃｸﾉ）                                                      */
/********************************************************************************/
/*変更履歴:                                                                     */
/*    2010/06 関 新規作成                                                       */
/********************************************************************************/


#include "alert.h"


#define FORMAT_LENGTH 511
#define BUFFER_LENGTH 1022
#define LEVEL_FATAL  1
#define LEVEL_ERROR  2
#define LEVEL_WARNING 3
#define LEVEL_INFORMATION 4
#define LEVEL_IGNORE  5

static S4 Alert_ReturnLevel[] = {
		COEXIT_FATAL,
		COEXIT_ERROR,
		COEXIT_SUCCESS,
		COEXIT_SUCCESS,
		COEXIT_SUCCESS,
		COEXIT_SUCCESS
};
typedef struct __ALERT_MESSAGE{
	U2 idx;
	UCHAR bOutput;
	UCHAR bLevel;
	PSZ  strMsg;
	UCHAR bNeedParam;
}ALERT_MESSAGE;
typedef struct __ALERT_SUB_MODULE{
	U2 idx;
	U2 max_msg;
	ALERT_MESSAGE * msgs;
}ALERT_SUB_MODULE;

typedef struct __ALERT_MODULE{
	U2 idx;
	U2 max_sub;
	ALERT_SUB_MODULE * sub_mods;
}ALERT_MODULE;

static ALERT_MESSAGE stAlertMsg_CppOpt[] = {
		{ CPP_OPT_WRONG, TRUE, LEVEL_WARNING, "Illegal Option:%s", TRUE },
		{ CPP_OPT_SHOULD_HAS_NOPARAM, TRUE, LEVEL_WARNING, "Useless parameter:%s", TRUE },
		{ CPP_OPT_SHOULD_HAS_PARAM, TRUE, LEVEL_WARNING, "Need parameter:%s", TRUE },
		{ CPP_OPT_ILLEGAL_PARAM, TRUE, LEVEL_WARNING, "Illegal parameter:%s", TRUE },
		{ 0, 0, 0, 0, 0 }
};
static ALERT_MESSAGE stAlertMsg_CppToken[] = {
		{ CPP_SRC_NEXTLINE_NOTFOUND,
				TRUE, LEVEL_INFORMATION,
				"The file should be ended by new-line character" ,
				FALSE
		},
		{ CPP_COMMENT_NOTEND,
				TRUE, LEVEL_ERROR,
				"The end character of comment was not found" ,
				FALSE
		},
		{ CPP_COMMAND_VSPACE_FOUND,
				FALSE, LEVEL_INFORMATION,
				"The vertical tab was found in the directive-line, before %s",
				TRUE
		},
		{ CPP_COMMAND_KEYWORD_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Illegal directive command",
				FALSE
		},
		{ CPP_PPTOKEN_CHAR_NOTEND,
				TRUE, LEVEL_ERROR,
				"Unfinished character constant",
				FALSE
		},
		{ CPP_PPTOKEN_HEADER_NOTEND,
				TRUE, LEVEL_ERROR,
				"Unfinished header name",
				FALSE
		},
		{ CPP_PPTOKEN_STRLITER_NOTEND,
				TRUE, LEVEL_ERROR,
				"Unfinished string literal",
				FALSE
		},
		{ CPP_PPTOKEN_INVALID,
				TRUE, LEVEL_ERROR,
				"Illegal preprocessing token",
				FALSE
		},
		{ 0, 0, 0, 0, 0 }
};
static ALERT_MESSAGE stAlertMsg_CppIf[] = {
		{ CPP_CONDEXP_SYNTAX_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Syntax error in directive condition expression",
				FALSE
		},
		{ CPP_CONDEXP_TYPE_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Not integer",
				FALSE
		},
		{ CPP_CONDEXP_TOKEN_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Illegal token was found in the condition expression",
				FALSE
		},
		{ CPP_IF_NONE_CONDEXP,
				TRUE, LEVEL_ERROR,
				"A condition expression is needed",
				FALSE
		},
		{ CPP_IF_CONDEXP_OPERATOR_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Illegal operator was found in the condition expression",
				FALSE
		},
		{ CPP_IF_CONDEXP_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"Overflow",
				FALSE
		},
		{ CPP_IF_CONDEXP_DIV_ZERO,
				TRUE, LEVEL_ERROR,
				"Divide 0",
				FALSE
		},
		{ CPP_CONDEXP_UNDEF_SYMBOL,
				TRUE, LEVEL_WARNING,
				"symbol is not defined",
				FALSE
		},
		{ CPP_IF_ENDIF_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"#endif is needed",
				FALSE
		},
		{ CPP_ELIF_IF_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"There is not #if/#ifdef/#ifndef before #elif",
				FALSE
		},
		{ CPP_IFDEF_ENDIF_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"#endif is needed",
				FALSE
		},
		{ CPP_IFDEF_CONDEXP_FORMAT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Illegal condition expression of #ifdef",
				FALSE
		},
		{ CPP_IFDEF_TOKEN_USELESS,
				TRUE, LEVEL_WARNING,
				"Useless token",
				FALSE
		},
		{ CPP_IFNDEF_ENDIF_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"#endif is needed",
				FALSE
		},
		{ CPP_IFNDEF_CONDEXP_FORMAT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Illegal condition expression of #ifndef",
				FALSE
		},
		{ CPP_IFNDEF_TOKEN_USELESS,
				TRUE, LEVEL_WARNING,
				"Useless token",
				FALSE
		},
		{ CPP_ELSE_IF_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"There is not #if/#ifdef/#ifndef before #elif",
				FALSE
		},
		{ CPP_ELSE_DUPLICATE,
				TRUE, LEVEL_ERROR,
				"#else are duplicated",
				FALSE
		},
		{ CPP_ELSE_DUPLICATE1ST,
				TRUE, LEVEL_ERROR,
				"The previous #else is here",
				FALSE
		},
		{ CPP_ELSE_TOKEN_USELESS,
				TRUE, LEVEL_WARNING,
				"Useless token",
				FALSE
		},
		{ CPP_ENDIF_IF_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"There is not #if/#ifdef/#ifndef before #endif",
				FALSE
		},
		{ CPP_ENDIF_TOKEN_USELESS,
				TRUE, LEVEL_WARNING,
				"Useless token",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CppDefine[] = {
		{ CPP_DEF_SSLEFT_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"Preprocessing token is needed before ##",
				FALSE
		},
		{ CPP_DEF_SSRIGHT_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"Preprocessing token is needed after ##",
				FALSE
		},
		{ CPP_DEF_SPARAM_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"A parameter is needed after #",
				FALSE
		},
		{ CPP_DEF_PARAMFORMAT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Syntax error in #define",
				FALSE
		},
		{ CPP_DEF_PARAM_DUPLICATE,
				TRUE, LEVEL_ERROR,
				"The parameter is duplicated",
				FALSE
		},
		{ CPP_DEF_MACRONAME_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"A macro name is needed",
				FALSE
		},
		{ CPP_DEF_MACRONAME_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Illegal macro name",
				FALSE
		},
		{ CPP_DEF_MACRONAME_FORBIDDEN,
				TRUE, LEVEL_WARNING,
				"The macro name can not be redefined:%s",
				TRUE
		},
		{ CPP_UND_MACRONAME_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"A macro name is needed",
				FALSE
		},
		{ CPP_UND_MACRONAME_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Illegal macro name",
				FALSE
		},
		{ CPP_UND_MACRONAME_FORBIDDEN,
				TRUE, LEVEL_WARNING,
				"The macro name can not be undefined:%s",
				FALSE
		},
		{ CPP_UND_TOKEN_USELESS,
				TRUE, LEVEL_WARNING,
				"Useless token",
				FALSE
		},
		{ CPP_DEF_MACRO_DUPLICATE,
				TRUE, LEVEL_WARNING,
				"The macro name is redefined",
				FALSE
		},
		{ CPP_DEF_MACRO_DUPLICATE1ST,
				TRUE, LEVEL_WARNING,
				"The previous definition is here",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CppError[] = {
		{ CPP_ERR_MESSAGE,
		  TRUE, LEVEL_ERROR,
		  "Error message:%s",
		  TRUE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CppInc[] = {
		{CPP_INC_OVERFLOW_NESTLVL,
				TRUE, LEVEL_ERROR,
				"The nesting level of #include is too large",
				FALSE
		},
		{CPP_INC_FORMAT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Syntax error in #include",
				FALSE
		},
		{CPP_INC_HEADER_TOOLONG,
				TRUE, LEVEL_WARNING,
				"The header name is too long",
				FALSE
		},
		{CPP_INC_HEADER_INVALID,
				TRUE, LEVEL_WARNING,
				"The header name is invalid",
				FALSE
		},
		{CPP_INC_FILE_NOTFOUND,
				TRUE, LEVEL_WARNING,
				"The header file is not found",
				FALSE
		},
		{CPP_INC_FILE_CANNOT_READ,
				TRUE, LEVEL_ERROR,
				"The header file can not be read",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CppLine[] = {
		{CPP_LINE_FORMAT_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"Syntax error in #line line",
				FALSE
		},
		{CPP_LINE_LINENO_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"Illegal line number",
				FALSE
		},
		{CPP_LINE_LINENO_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"The line number is too large",
				FALSE
		},
		{CPP_LINE_FILEPATH_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"Illegal file path",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_Pragma[] = {
		{
				CPP_PRAGMA_ENDASM_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"#pragma directive is needed to finish assembly lines" ,
				FALSE
		},
		{
				CPP_PRAGMA_ASM_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"#pragma directive is needed to start assembly lines" ,
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_Rep[] = {
		{
				CPP_MACRO_COMMAND_INARG,
				TRUE, LEVEL_WARNING,
				"Directive is found in macro's argument",
				FALSE
		},
		{
				CPP_MACRO_FORMAT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Syntax error in macro calling",
				FALSE
		},
		{
				CPP_MACRO_SSTOKEN_CANNOTMERGE,
				TRUE, LEVEL_WARNING,
				"The tokens can not be concatenated",
				FALSE,
		},
		{
				CPP_MACRO_ARGNUM_DIFF,
				TRUE, LEVEL_ERROR,
				"The number of arguments is different with the number of parameters",
				FALSE,
		},
		{
				CPP_MACRO_ARGNUM_DIFF_DEFLOC,
				TRUE, LEVEL_ERROR,
				"The macro definition is here",
				FALSE,
		},
		{
				CPP_MACRO_BLANK_ARG,
				TRUE, LEVEL_ERROR,
				"There is no preprocessing token in macro's argument",
				FALSE,
		},
		{ 0,0,0,0,0}
};
static ALERT_SUB_MODULE stAlertSubMod_Cpp[] = {
		{ cpp_sub_option, CPP_OPT_MSG_END, stAlertMsg_CppOpt },
		{ cpp_sub_token, CPP_PPTOKEN_MSG_END, stAlertMsg_CppToken },
		{ cpp_sub_if, CPP_IF_MSG_END, stAlertMsg_CppIf },
		{ cpp_sub_define, CPP_DEF_MSG_END, stAlertMsg_CppDefine },
		{ cpp_sub_error, CPP_ERR_MSG_END, stAlertMsg_CppError },
		{ cpp_sub_include, CPP_INC_MSG_END, stAlertMsg_CppInc },
		{ cpp_sub_line,CPP_LINE_MSG_END, stAlertMsg_CppLine },
		{ cpp_sub_pragma,CPP_PRAGMA_MSG_END, stAlertMsg_Pragma },
		{ cpp_sub_replace, CPP_MACRO_MSG_END,stAlertMsg_Rep },
		{ 0, 0,0 }
};
static ALERT_MESSAGE stAlertMsg_CcOpt[] = {
		{
				CC_OPT_WRONG,
				TRUE, LEVEL_ERROR,
				"Option error",
				FALSE
		},
		{ CC_OPT_SHOULD_HAS_NOPARAM, TRUE, LEVEL_WARNING, "Useless parameter:%s", TRUE },
		{ CC_OPT_SHOULD_HAS_PARAM, TRUE, LEVEL_WARNING, "Need parameter:%s", TRUE },
		{ CC_OPT_ILLEGAL_PARAM, TRUE, LEVEL_WARNING, "Illegal parameter:%s", TRUE },
		{ 0,0,0,0,0}
};

static ALERT_MESSAGE stAlertMsg_CcToken[] = {
		{
				CC_TOKEN_UNEXPECTED,
				TRUE, LEVEL_ERROR,
				"Illegal token",
				FALSE
		},
		{
				CC_TOKEN_STRING_KIND_DIFF,
				TRUE, LEVEL_WARNING,
				"The kind of strings is different"
		},
		{
				CC_TOKEN_STRING_HEX_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"The hex escape sequence in the string is illegal",
				FALSE
		},
		{
				CC_TOKEN_STRING_HEX_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"The hex escape sequence in the string is overflowed",
				FALSE
		},
		{
				CC_TOKEN_STRING_OCT_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"The octal escape sequence in the string is overflowed",
				FALSE
		},
		{
				CC_TOKEN_STRING_OCT_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"The octal escape sequence in the string is illegal",
				FALSE
		},
		{
				CC_TOKEN_CHAR_UNKNOWN_ESCAPE,
				TRUE, LEVEL_WARNING,
				"Illegal escape sequence in the string",
				FALSE
		},
		{
				CC_TOKEN_NUMBER_HEX_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"The hex constant is overflowed",
				FALSE
		},
		{
				CC_TOKEN_NUMBER_HEX_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The hex constant is illegal",
				FALSE
		},
		{
				CC_TOKEN_NUMBER_OCT_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"The octal constant is overflowed",
				FALSE
		},
		{
				CC_TOKEN_NUMBER_OCT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The octal constant is illegal",
				FALSE
		},
		{
				CC_TOKEN_NUMBER_FLOAT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The floating constant is illegal",
				FALSE
		},
		{
				CC_TOKEN_NUMBER_OVERFLOW,
				TRUE, LEVEL_ERROR,
				"The integer constant is overflowed",
				FALSE
		},
		{
				CC_TOKEN_NUMBER_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The integer constant is illegal",
				FALSE
		},
		{
				CC_TOKEN_CHAR_BLANK,
				TRUE, LEVEL_WARNING,
				"Blank character constant",
				FALSE
		},
		{
				CC_TOKEN_CHAR_HEX_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"The hex escape sequence in the character constant is illegal",
				FALSE
		},
		{
				CC_TOKEN_CHAR_HEX_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"The hex escape sequence in the character constant is overflowed",
				FALSE
		},
		{
				CC_TOKEN_CHAR_OCT_OVERFLOW,
				TRUE, LEVEL_WARNING,
				"The octal escape sequence in the character constant is overflowed",
				FALSE
		},
		{
				CC_TOKEN_CHAR_OCT_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"The octal escape sequence in the character constant is illegal",
				FALSE
		},
		{
				CC_TOKEN_CHAR_MULTIBYTE,
				TRUE, LEVEL_WARNING,
				"The multi-bytes character was found in character constant",
				FALSE
		},
		{
				CC_TOKEN_CHAR_MULTICHAR,
				TRUE, LEVEL_WARNING,
				"The multi character were found in character constant",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CcDecl[] = {
		{
				CC_DECL_SYNTAX_ERROR,
				TRUE, LEVEL_ERROR,
				"Syntax error in a declaration",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The parameters of function are duplicated",
				FALSE
		},
		{
				CC_DECL_FUNC_OLDSTYLE_DECLIST_WRONGNAME,
				TRUE, LEVEL_ERROR,
				"(Old style)The identifier of declaration list is not any parameter of the function",
				FALSE
		},
		{
				CC_DECL_FUNC_OLDSTYLE_MISUSE,
				TRUE, LEVEL_ERROR,
				"Old style of function declaration can be used only in a function definition",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_NOTYPE,
				TRUE, LEVEL_ERROR,
				"The type of the parameter is not defined",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_NOSIZE,
				TRUE, LEVEL_ERROR,
				"The type of the parameter has no size",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_CLASS_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The storage class of the parameter is illegal",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_INITIALLED,
				TRUE, LEVEL_ERROR,
				"The parameter has been initialed",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_FORMAT_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The formation of ellipsis is wrong",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_NONAME,
				TRUE, LEVEL_ERROR,
				"The parameter has no name",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_DUPLICATE_TYPEDEF,
				TRUE, LEVEL_WARNING,
				"The name of parameter is same with a typedef identifier",
				FALSE
		},
		{
				CC_DECL_FUNC_HAS_QUALIFIER,
				TRUE, LEVEL_WARNING,
				"The function type has type qualifier",
				FALSE
		},
		{
				CC_DECL_EXTERN_FUNC_IN_FUNC,
				TRUE, LEVEL_ERROR,
				"The external function is defined in a function",
				FALSE
		},
		{
				CC_DECL_FUNC_IN_FUNC,
				TRUE, LEVEL_WARNING,
				"The function is defined in a function",
				FALSE
		},
		{
				CC_DECL_FUNC_CLASS_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"The storage class of the function is illegal",
				FALSE
		},
		{
				CC_DECL_FUNC_PARAM_CHANGEABLE,
				TRUE, LEVEL_INFORMATION,
				"The number of the parameters is variable",
				FALSE
		},
		{
				CC_DECL_FUNC_CLASS_NEARPOINTER,
				TRUE, LEVEL_WARNING,
				"The pointer to function type is qualified by `near",
				FALSE
		},
		{
				CC_DECL_FUNC_RETURNTYPE_ILLEGAL,
				TRUE, LEVEL_WARNING,
				"The return type of function is not correct",
				FALSE
		},
		{
				CC_DECL_FUNC_SYNTAX_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The formation of the function definition is illegal",
				FALSE
		},
		{
				CC_DECL_MEMBER_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The members are duplicated",
				FALSE
		},
		{
				CC_DECL_MEMBER_1ST_NONAME,
				TRUE, LEVEL_ERROR,
				"The previous one is here",
				FALSE
		},
		{
				CC_DECL_MEMBER_NOSIZE,
				TRUE, LEVEL_ERROR,
				"The type of member has no size",
				FALSE
		},
		{
				CC_DECL_MEMBER_BIT_NEED_CONSTANT,
				TRUE, LEVEL_ERROR,
				"The width of bit-field must be constant",
				FALSE
		},
		{
				CC_DECL_MEMBER_BIT_0BIT_SYM,
				TRUE, LEVEL_ERROR,
				"The bit-field with name has no width",
				FALSE
		},
		{
				CC_DECL_MEMBER_BIT_TYPE_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The type of bit-field is illegal",
				FALSE
		},
		{
				CC_DECL_MEMBER_BIT_WIDTH_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The width of bit-field must be a positive integer constant",
				FALSE
		},
		{
				CC_DECL_MEMBER_BIT_WIDTH_OVERFLOW,
				TRUE, LEVEL_ERROR,
				"The width of bit-field is too large",
				FALSE
		},
		{
				CC_DECL_MEMBER_BIT_WIDTH_NONE,
				TRUE, LEVEL_ERROR,
				"The width of bit-field is not defined",
				FALSE
		},
		{
				CC_DECL_MEMBER_HAS_STORAGECLASS,
				TRUE, LEVEL_WARNING,
				"The member has a storage class",
				FALSE
		},
		{
				CC_DECL_MEMBER_DUPLICATE_TYPEDEF,
				TRUE, LEVEL_ERROR,
				"The member has same name with a typedef identifier",
				FALSE
		},
		{
				CC_DECL_MEMBER_DUPLICATE_TYPEDEF1ST,
				TRUE, LEVEL_ERROR,
				"The typedef identifier is here",
				FALSE
		},
		{
				CC_DECL_STRUCT_NONAMED_MEMBER,
				TRUE, LEVEL_ERROR,
				"There is no named member",
				FALSE
		},
		{
				CC_DECL_ENUMCONST_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The enumeration constant are duplicated",
				FALSE
		},
		{
				CC_DECL_ENUMCONST_OVERLAP_1ST,
				TRUE, LEVEL_ERROR,
				"The previous one is here",
				FALSE
		},
		{
				CC_DECL_ENUMCONST_INITEXP_WRONGTYPE,
				TRUE, LEVEL_ERROR,
				"The value of enumeration constant must be integer",
				FALSE
		},
		{
				CC_DECL_ENUMCONST_INITEXP_OVERFLOW,
				TRUE, LEVEL_ERROR,
				"The value of enumeration constant is too large",
				FALSE
		},
		{
				CC_DECL_INBLOCK_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The identifiers are duplicated",
				FALSE
		},
		{
				CC_DECL_INBLOCK_OVERLAP1ST,
				TRUE, LEVEL_ERROR,
				"The previous one is here",
				FALSE
		},
		{
				CC_DECL_VARI_INBLOCK_EXTERN_INITIALLED,
				TRUE, LEVEL_ERROR,
				"The external identifier in block is initialed",
				FALSE
		},
		{
				CC_DECL_VARI_TYPE_INCOMPLETE,
				TRUE, LEVEL_ERROR,
				"The identifier has an incomplete type",
				FALSE
		},
		{
				CC_DECL_TEMPORARY_DUPLICATE_TYPEDEF,
				TRUE, LEVEL_ERROR,
				"The temporary variable has same name with a typedef identifier",
				FALSE
		},
		{
				CC_DECL_TEMPORARY_DUPLICATE_TYPEDEF1ST,
				TRUE, LEVEL_ERROR,
				"The typedef identifier is here",
				FALSE
		},
		{
				CC_DECL_TAG_INBLOCK_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The tag is duplicated",
				FALSE
		},
		{
				CC_DECL_TAG_INBLOCK_OVERLAP_1ST,
				TRUE, LEVEL_ERROR,
				"The previous one is here",
				FALSE
		},
		{
				CC_DECL_TAG_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"undefined tag",
				FALSE
		},
		{
				CC_DECL_CLASS_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The storage classes are duplicated",
				FALSE
		},
		{
				CC_DECL_CLASS_NOT_GBLCLASS,
				TRUE, LEVEL_ERROR,
				"The storage class should not be used in file scope",
				FALSE
		},
		{
				CC_DECL_QUALIFIER_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The type qualifiers are duplicated",
				FALSE
		},
		{
				CC_DECL_QUALIFIER_RESTRICT_MISSUSE,
				TRUE, LEVEL_ERROR,
				"The type qualifiers `restrict must be used for pointer",
				FALSE
		},
		{
				CC_DECL_SPECIFIER_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The type specifier is not correct",
				FALSE
		},
		{
				CC_DECL_SPECIFIER_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The type specifier is not correct",
				FALSE
		},
		{
				CC_DECL_SPECIFIER_INEXISTENCE,
				TRUE, LEVEL_ERROR,
				"The combination of type specifier is not a legal type",
				FALSE
		},
		{
				CC_DECL_SPECIFIER_NOTFOUND,
				TRUE, LEVEL_ERROR,
				"No type is indicated",
				FALSE
		},
		{
				CC_DECL_TYPENAME_HASSYMBOL,
				TRUE, LEVEL_ERROR,
				"Identifier was found in type name declaration",
				FALSE
		},
		{
				CC_DECL_TYPEDEF_SYM_INITIALLED,
				TRUE, LEVEL_ERROR,
				"The typedef identifier has an init-declarator",
				FALSE
		},
		{
				CC_DECL_ARRAY_ORITYPE_FUNC,
				TRUE, LEVEL_ERROR,
				"The element type of an array is function",
				FALSE
		},
		{
				CC_DECL_ARRAY_ORITYPE_INCOMPLETE,
				TRUE, LEVEL_ERROR,
				"The element type of an array is incomplete",
				FALSE
		},
		{
				CC_DECL_ARRAY_INDEX_NOTINTEGER,
				TRUE, LEVEL_ERROR,
				"The size of array is not integer",
				FALSE
		},
		{
				CC_DECL_ARRAY_INDEX_NEGATIVE,
				TRUE, LEVEL_ERROR,
				"The size of array is not positive",
				FALSE
		},
		{
				CC_DECL_ARRAY_CLASS_REGISTER,
				TRUE, LEVEL_ERROR,
				"The array has a `register storage class",
				FALSE
		},
		{
				CC_DECL_DECLARE_NOTHING,
				TRUE, LEVEL_ERROR,
				"Empty declaration",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CcStmt[] = {
		{
				CC_STMT_SYNTAX_ERROR,
				TRUE, LEVEL_ERROR,
				"Syntax error in statement",
				FALSE
		},
		{
				CC_STMT_INBLOCK_DEC_AFTER_STMT,
				TRUE, LEVEL_WARNING,
				"Declaration in the statement-list",
				FALSE
		},
		{
				CC_STMT_FOR_INITEXP_DECL,
				TRUE, LEVEL_WARNING,
				"Declaration in the first expression position of for statement",
				FALSE
		},
		{
				CC_STMT_UNKNOWN_KEYWORD,
				TRUE, LEVEL_ERROR,
				"Illegal keyword",
				FALSE
		},
		{
				CC_STMT_NEED_BODY,
				TRUE, LEVEL_ERROR,
				"The body statement is needed",
				FALSE
		},
		{
				CC_STMT_CONTINUE_OUTLOOP,
				TRUE, LEVEL_ERROR,
				"`continue was found out of loop",
				FALSE
		},
		{
				CC_STMT_BREAK_OUTLOOP_OR_SWITCH,
				TRUE, LEVEL_ERROR,
				"`break was found out of loop and switch",
				FALSE
		},
		{
				CC_STMT_CASE_OUTSWITCH,
				TRUE, LEVEL_ERROR,
				"`case was found out of switch",
				FALSE
		},
		{
				CC_STMT_CASE_NEED_VALUE,
				TRUE, LEVEL_ERROR,
				"A Value is needed after `case statement",
				FALSE
		},
		{
				CC_STMT_CASE_NEED_CONSTANT,
				TRUE, LEVEL_ERROR,
				"Constant is needed after `case statement",
				FALSE
		},
		{
				CC_STMT_CASE_NEED_INTEGER,
				TRUE, LEVEL_ERROR,
				"Integer is needed after `case statement",
				FALSE
		},
		{
				CC_STMT_CASE_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The values of `case statements in same switch statement are equal",
				FALSE
		},
		{
				CC_STMT_CASE_OVERLAP1ST,
				TRUE, LEVEL_ERROR,
				"The previous `case statement is here",
				FALSE
		},
		{
				CC_STMT_DEFAULT_OUTSWITCH,
				TRUE, LEVEL_ERROR,
				"`default was found out of switch",
				FALSE
		},
		{
				CC_STMT_DEFAULT_OVERLAP,
				TRUE, LEVEL_ERROR,
				"`default statement is duplicated",
				FALSE
		},
		{
				CC_STMT_DEFAULT_OVERLAP1ST,
				TRUE, LEVEL_ERROR,
				"The previous `default statement is here",
				FALSE
		},
		{
				CC_STMT_CONDEXP_NEED_SCALAR,
				TRUE, LEVEL_ERROR,
				"The type of condition expression must be a scalar type",
				FALSE
		},
		{
				CC_STMT_CONDEXP_NEED_INTEGER,
				TRUE, LEVEL_ERROR,
				"The type of condition expression must be a integer type",
				FALSE
		},
		{
				CC_STMT_LABEL_OVERLAP,
				TRUE, LEVEL_ERROR,
				"The label statements are duplicated in a function",
				FALSE
		},
		{
				CC_STMT_LABEL_OVERLAP1ST,
				TRUE, LEVEL_ERROR,
				"The previous label statement is here",
				FALSE
		},
		{
				CC_STMT_NEED_SYMBOL,
				TRUE, LEVEL_ERROR,
				"An identifier is needed",
				FALSE
		},
		{
				CC_STMT_RETURN_VALUE_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"The return statement is not compatible with the type of the function definition",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CcExpr[] = {
		{
				CC_EXP_SYNTAX_ERROR,
				TRUE, LEVEL_ERROR,
				"Syntax error in an expression",
				FALSE
		},
		{
				CC_EXP_IDENTIFIER_UNKNOWN,
				TRUE, LEVEL_ERROR,
				"Undefined identifier in an expression",
				FALSE
		},
		{
				CC_EXP_SIZEOF_TYPE_FUNC,
				TRUE, LEVEL_ERROR,
				"The parameter of `sizeof is a function",
				FALSE
		},
		{
				CC_EXP_SIZEOF_TYPE_NOSIZE,
				TRUE, LEVEL_ERROR,
				"The parameter of `sizeof has no size",
				FALSE
		},
		{
				CC_EXP_OP_ERROR,
				TRUE, LEVEL_ERROR,
				"Operator `? is needed before operator `:",
				FALSE
		},
		{
				CC_EXP_FORMAT_ERROR,
				TRUE, LEVEL_ERROR,
				"Illegal expression",
				FALSE
		},
		{
				CC_EXP_VARI_MULTIASSIGN,
				TRUE, LEVEL_ERROR,
				"A variable is assigned more than once in an expression",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_INTEGER,
				TRUE, LEVEL_ERROR,
				"An integer type is needed",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_ARITH,
				TRUE, LEVEL_ERROR,
				"An arithmetic type is needed",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_ILLEGAL_ADD,
				TRUE, LEVEL_ERROR,
				"The operands of binary additive operator `+ are illegal",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_ILLEGAL_SUB,
				TRUE, LEVEL_ERROR,
				"The operands of binary subtraction operator `- are illegal",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_POINTER,
				TRUE, LEVEL_ERROR,
				"A pointer is needed",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_STRUCT_UNION,
				TRUE, LEVEL_ERROR,
				"A struct or union is needed",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_SAME_POINTER,
				TRUE, LEVEL_ERROR,
				"The two operands must have compatible pointer types",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_CANNOT_BE_FUNC,
				TRUE, LEVEL_ERROR,
				"A function was found",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_CANNOT_BE_BIT,
				TRUE, LEVEL_ERROR,
				"A bit-field was found",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_SCALAR,
				TRUE, LEVEL_ERROR,
				"A scalar type is needed",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_1ST_SCALAR,
				TRUE, LEVEL_ERROR,
				"A scalar type is needed for the first operand",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_SAME_TYPE,
				TRUE, LEVEL_ERROR,
				"The two operands must have compatible types",
				FALSE
		},
		{
				CC_EXP_ARGUMENT_NEED_ASSIGNABLE_TYPE,
				TRUE, LEVEL_ERROR,
				"Passing the argument from an incompatible pointer type",
				FALSE
		},
		{
				CC_EXP_OPERAND_NEED_MODIFIABLE,
				TRUE, LEVEL_ERROR,
				"The operand is not modifiable",
				FALSE
		},
		{
				CC_EXP_OPERANDTYPE_NEED_FUNCTION,
				TRUE, LEVEL_ERROR,
				"A function is needed",
				FALSE
		},
		{
				CC_EXP_FUNCCALL_PARAM_NUM_DIFF,
				TRUE, LEVEL_ERROR,
				"The number of arguments is not equal to the number of parameters",
				FALSE
		},
		{
				CC_EXP_ASSIGNMENT_DIFFPTR,
				TRUE, LEVEL_ERROR,
				"The pointer is assigned from an incompatible type",
				FALSE
		},
		{
				CC_EXP_ASSIGNMENT_PTR_DIFFQUAL,
				TRUE, LEVEL_ERROR,
				"The pointer is assigned from a type that has more type qualifiers",
				FALSE
		},
		{
				CC_EXP_ASSIGNMENT_DIFFTYPE,
				TRUE, LEVEL_ERROR,
				"The operand is assigned from an incompatible type",
				FALSE
		},
		{
				CC_EXP_ASSIGNMENT_TYPE_DIFFQUAL,
				TRUE, LEVEL_ERROR,
				"The operand is assigned from a type that has more type qualifiers",
				FALSE
		},
		{
				CC_EXP_OPERAND_ARRAY_REGISTER,
				TRUE, LEVEL_ERROR,
				"The operand should not be an array with `register storage class",
				FALSE
		},
		{
				CC_EXP_FUNCCALL_BEFORE_DECLARE,
				TRUE, LEVEL_ERROR,
				"Implicit declaration of function",
				FALSE
		},
		{
				CC_EXP_STATEMENT_IN_EXP,
				TRUE, LEVEL_ERROR,
				"(gnu)A statement was found in an expression",
				FALSE
		},
		{
				CC_EXP_OPERAND_WRONGMEMBER,
				TRUE, LEVEL_ERROR,
				"The field name is not correct",
				FALSE
		},
		{
				CC_EXP_OP_ADDRESS_OF_REGISTER,
				TRUE, LEVEL_ERROR,
				"Cannot get the address from an object with `register storage class",
				FALSE
		},
		{
				CC_EXP_OP_ADDRESS_OF_BIT,
				TRUE, LEVEL_ERROR,
				"Cannot get the address from a bit-field",
				FALSE
		},
		{
				CC_EXP_OPERAND_ILLEGAL,
				TRUE, LEVEL_ERROR,
				"Typedef identifier was found in an expression",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CcInit[] = {
		{
				CC_INITEXP_SYNTAX_ERROR,
				TRUE, LEVEL_ERROR,
				"Syntax error in initializer expression",
				FALSE
		},
		{
				CC_INITEXP_NEED_CONSTEXP,
				TRUE, LEVEL_ERROR,
				"The initializer element is not constant",
				FALSE
		},
		{
				CC_INITEXP_DESIGNATION_NEED_CONST,
				TRUE, LEVEL_ERROR,
				"The array index of designation is not constant",
				FALSE
		},
		{
				CC_INITEXP_DESIGNATION_NEED_INTEGER,
				TRUE, LEVEL_ERROR,
				"The array index of designation is not integer",
				FALSE
		},
		{
				CC_INITEXP_DESIGNATION_NEED_POSITIVE,
				TRUE, LEVEL_ERROR,
				"The array index of designation is not positive",
				FALSE
		},
		{
				CC_INITEXP_DESIGNATION_OVERFLOW,
				TRUE, LEVEL_ERROR,
				"The array index of designation is too large",
				FALSE
		},
		{
				CC_INITEXP_DESIGNATION_UNKNOWN_SYM,
				TRUE, LEVEL_ERROR,
				"The field name of designation is unknown",
				FALSE
		},
		{
				CC_INITEXP_DESIGNATION_MEM_MISSUSE,
				TRUE, LEVEL_ERROR,
				"The field name is not in struct or union initializer",
				FALSE
		},
		{
				CC_INITEXP_DESIGNATION_ARRAY_MISSUSE,
				TRUE, LEVEL_ERROR,
				"The array index is not in array initializer",
				FALSE
		},
		{
				CC_INITEXP_EXCESS_BRACE,
				TRUE, LEVEL_ERROR,
				"The brace is not needed",
				FALSE
		},
		{
				CC_INITEXP_NEED_BRACE,
				TRUE, LEVEL_ERROR,
				"The brace is needed",
				FALSE
		},
		{
				CC_INITEXP_EXCESS_ELEMENTS,
				TRUE, LEVEL_ERROR,
				"The initializer element is too many",
				FALSE
		},
		{
				CC_INITEXP_UNCOMPATIBABLE_TYPE,
				TRUE, LEVEL_ERROR,
				"The initializer element has not a compatible type",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CcCalc[] = {
		{
				CC_CONSTEXP_CAL_DIV0,
				TRUE, LEVEL_ERROR,
				"Divide 0",
				FALSE
		},
		{
				CC_CONSTEXP_CAL_OVERFLOW,
				TRUE, LEVEL_ERROR,
				"Overflow",
				FALSE
		},
		{
				CC_CONSTEXP_CAST_FLOAT2INT_OVERFLOW,
				TRUE, LEVEL_ERROR,
				"Overflow when casting from floating to integer",
				FALSE
		},
		{
				CC_CONSTEXP_CAST_FLOAT2FLOAT_OVERFLOW,
				TRUE, LEVEL_ERROR,
				"Overflow when cast from floating to floating",
				FALSE
		},
		{
				CC_CONSTEXP_SHIFT_BIT_MINUS,
				TRUE, LEVEL_ERROR,
				"The right operand of shift operand has a negative value",
				FALSE
		},
		{
				CC_CONSTEXP_SHIFT_BIT_LARGER,
				TRUE, LEVEL_ERROR,
				"The right operand of shift operand is too large",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CcLink[] = {
		{
				CC_SYMBOL_TYPE_DIFF,
				TRUE, LEVEL_ERROR,
				"Conflicting types for identifier",
				FALSE
		},
		{
				CC_SYMBOL_TYPE_DIFF1ST,
				TRUE, LEVEL_ERROR,
				"The previous one is here",
				FALSE
		},
		{
				CC_SYMBOL_NOSIZE,
				TRUE, LEVEL_ERROR,
				"The object has no size",
				FALSE
		},
		{
				CC_SYMBOL_REDEFINITION,
				TRUE, LEVEL_ERROR,
				"The identifier is redefined",
				FALSE
		},
		{
				CC_SYMBOL_REDEFINITION1ST,
				TRUE, LEVEL_ERROR,
				"The previous one is here",
				FALSE
		},
		{
				CC_SYMBOL_NODEFINITION,
				TRUE, LEVEL_ERROR,
				"The identifier is not defined",
				FALSE
		},
		{
				CC_DECL_DOUBLE_LINKAGE,
				TRUE, LEVEL_ERROR,
				"The identifier's linkage is confused",
				FALSE
		},
		{
				CC_DECL_DOUBLE_LINKAGE1ST,
				TRUE, LEVEL_ERROR,
				"The previous one is here",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_MESSAGE stAlertMsg_CcAsm[] = {
		{
				CC_ASM_SYNTAX_ERROR,
				TRUE, LEVEL_ERROR,
				"Syntax error in assembly statement",
				FALSE
		},
		{
				CC_ASM_SKIPLINE,
				TRUE, LEVEL_WARNING,
				"Skip assembly line",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_SUB_MODULE stAlertSubMod_Cc[] = {
		{ cc_sub_option, CC_OPT_MSG_END, stAlertMsg_CcOpt },
		{ cc_sub_token,CC_TOKEN_MSG_END,stAlertMsg_CcToken },
		{ cc_sub_decl, CC_DECL_MSG_END,stAlertMsg_CcDecl },
		{ cc_sub_statement, CC_STMT_MSG_END, stAlertMsg_CcStmt },
		{ cc_sub_expression, CC_EXP_MSG_END,stAlertMsg_CcExpr },
		{ cc_sub_initializer, CC_INITEXP_MSG_END, stAlertMsg_CcInit},
		{ cc_sub_calcute, CC_CONSTEXP_MSG_END, stAlertMsg_CcCalc },
		{ cc_sub_link, CC_LINK_MSG_END, stAlertMsg_CcLink },
		{ cc_sub_asm, CC_ASM_MSG_END, stAlertMsg_CcAsm },
		{ 0, 0, 0 }
};
static ALERT_MESSAGE stAlertMsg_File[] = {
		{ FILE_TOOMANY,
			TRUE, LEVEL_FATAL,
			"There is no room to open a new file",
			FALSE
		},
		{ FILE_CANNOTOPEN,
			TRUE, LEVEL_FATAL,
			"Cannot open the file",
			FALSE
		},
		{ FILE_CANNOTCLOSE,
			TRUE, LEVEL_FATAL,
			"Cannot close the file",
			FALSE
		},
		{ FILE_CANNOTREAD,
			TRUE, LEVEL_FATAL,
			"Cannot read from the file",
			FALSE
		},
		{ FILE_CANNOTWRITE,
			TRUE, LEVEL_FATAL,
			"Cannot write to the file",
			FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_SUB_MODULE stAlertSubMod_file[] = {
		{file_all, FILE_MSG_END, stAlertMsg_File},
		{ 0, 0,0 }
};
static ALERT_MESSAGE stAlertMsg_Mem[] = {
		{ MEMORY_ERROR,
			TRUE, LEVEL_FATAL,
			"Memory error",
			FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_SUB_MODULE stAlertSubMod_Memory[] = {
		{mem_all, MEMORY_MSG_END, stAlertMsg_Mem},
		{ 0, 0,0 }
};
static ALERT_MESSAGE stAlertMsg_Table[] = {
		{ TABLE_NEW_MEM,
				TRUE, LEVEL_FATAL,
				"Error occurs when allocating new memory",
				FALSE
		},
		{ TABLE_REALLOC_MEM,
				TRUE, LEVEL_FATAL,
				"Error occurs when reallocating memory",
				FALSE
		},
		{ TABLE_FREE_MEM,
				TRUE, LEVEL_FATAL,
				"Error occurs when freeing memory",
				FALSE
		},
		{ TABLE_ALLOC_OVERFLOW,
				TRUE, LEVEL_FATAL,
				"The table is overflow",
				FALSE
		},
		{ BUFFER_ALLOC_OVERFLOW,
				TRUE, LEVEL_FATAL,
				"The buffer is overflow",
				FALSE
		},
		{ TABLE_ALLOC_UNDERFLOW,
				TRUE, LEVEL_FATAL,
				"The table is underflow",
				FALSE
		},
		{ BUFFER_ALLOC_UNDERFLOW,
				TRUE, LEVEL_FATAL,
				"The buffer is underflow",
				FALSE
		},
		{ TABLE_DATA_LOST,
				TRUE, LEVEL_FATAL,
				"Data is lost when swap-in",
				FALSE
		},
		{ TABLE_LARGER_INDEX,
				TRUE, LEVEL_ERROR,
				"The index is too large",
				FALSE
		},
		{ TABLE_DATA_MISTAKE,
				TRUE, LEVEL_ERROR,
				"The data in table is wrong",
				FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_SUB_MODULE stAlertSubMod_Table[] = {
		{tab_all, TABLE_MSG_END, stAlertMsg_Table},
		{ 0, 0,0 }
};
static ALERT_MESSAGE stAlertMsg_CppRes[] = {

		{ 0,0,0,0,0}
};
static ALERT_SUB_MODULE stAlertSubMod_CppRes[] = {
		{cpp_res_all, CPPRES_MSG_END, stAlertMsg_CppRes},
		{ 0, 0,0 }
};
static ALERT_MESSAGE stAlertMsg_Link[] = {
		{ LINK_FUNCTION_TYPE_DIFF,
			TRUE, LEVEL_WARNING,
			"The types of function are different",
			FALSE
		},
		{ LINK_SYMBOL_TYPE_DIFF,
			TRUE, LEVEL_WARNING,
			"The types of variable are different",
			FALSE
		},
		{ LINK_SYMBOL_NOSIZE,
			TRUE, LEVEL_WARNING,
			"The type of variable is not defined",
			FALSE
		},
		{ LINK_FUNCTION_REDEFINITION,
			TRUE, LEVEL_WARNING,
			"The function's definitions are duplicated",
			FALSE
		},
		{ LINK_SYMBOL_REDEFINITION,
			TRUE, LEVEL_WARNING,
			"The variable's definitions are duplicated",
			FALSE
		},
		{ LINK_FUNCTION_NODEFINITION,
			TRUE, LEVEL_WARNING,
			"The function is not defined",
			FALSE
		},
		{ LINK_SYMBOL_NODEFINITION,
			TRUE, LEVEL_WARNING,
			"The variable is not defined",
			FALSE
		},
		{ 0,0,0,0,0}
};
static ALERT_SUB_MODULE stAlertSubMod_Link[] = {
		{link_all, LINK_MSG_END, stAlertMsg_Link},
		{ 0, 0,0 }
};
static ALERT_MESSAGE stAlertMsg_Ast_Tr[] = {
		{ TR_AST_ENTRY_WRONG,
			TRUE, LEVEL_WARNING,
			"The trace entry is illegal.( for Syntax )",
			FALSE
		},
};
static ALERT_MESSAGE stAlertMsg_Cmd_Tr[] = {
		{ TR_CMD_ENTRY_WRONG,
			TRUE, LEVEL_WARNING,
			"The trace entry '%s is illegal.( for LinkCommand )",
			TRUE
		},
};
static ALERT_SUB_MODULE stAlertSubMod_Ast_Tr[] = {
		{ast_trace_all, TR_AST_ENTRY_END, stAlertMsg_Ast_Tr},
		{ 0, 0,0 }
};
static ALERT_SUB_MODULE stAlertSubMod_Cmd_Tr[] = {
		{cmd_trace_all, TR_CMD_ENTRY_END, stAlertMsg_Cmd_Tr},
		{ 0, 0,0 }
};
static ALERT_MODULE stAlertModule[] = {
		{ mod_file, file_max, stAlertSubMod_file },
		{ mod_memory, mem_max, stAlertSubMod_Memory },
		{ mod_table, tab_max,stAlertSubMod_Table },
		{ mod_cpp, cpp_sub_max, stAlertSubMod_Cpp },
		{ mod_cpp_result, cpp_res_max, stAlertSubMod_CppRes },
		{ mod_cc, cc_sub_max, stAlertSubMod_Cc },
		{ mod_link, link_max, stAlertSubMod_Link },
		{ mod_ast_trace, ast_trace_max, stAlertSubMod_Ast_Tr },
		{ mod_cmd_trace, cmd_trace_max, stAlertSubMod_Cmd_Tr },
		{ 0, 0, 0 }
};
static CHAR	szPath[OS_FULLPATH+4];
static CHAR	msgBuffer[OS_FULLPATH+4];
static ALERT_MODULE *alertGetModule( U2 mod_idx ){
	S4 i;
	for( i = 0; stAlertModule[i].idx != 0 ; i++ ){
		if( stAlertModule[i].idx == mod_idx ){
			return &stAlertModule[i];
		}
	}
	return NULL;
}
static ALERT_SUB_MODULE *alertGetSubModule( ALERT_SUB_MODULE * begin, U2 mod_idx ){
	S4 i;
	for( i = 0; begin[i].idx != 0 ; i++ ){
		if( begin[i].idx == mod_idx ){
			return &begin[i];
		}
	}
	return NULL;
}
static ALERT_MESSAGE *alertGetSubMessage( ALERT_MESSAGE * begin, U2 code_idx ){
	S4 i;
	for( i = 0; begin[i].idx != 0 ; i++ ){
		if( begin[i].idx == code_idx ){
			return &begin[i];
		}
	}
	return NULL;
}
S4  AlertThrowWaring( U4 code, AST astCodeScp, PSZ pszParameter, ALERT_MSG_PARAM * param ){
	U2  mod_idx = module_get(code);
	U2  submod_idx = submod_get( code );
	U2  code_idx = (code&0x000000FF);
	ALERT_MODULE * pMod = NULL;
	ALERT_SUB_MODULE * pSubMod = NULL;
	ALERT_MESSAGE * msg = NULL;

	if( mod_idx < mod_max ){
		pMod = &stAlertModule[mod_idx-1];
		if( pMod->idx != mod_idx ){
			pMod = alertGetModule( mod_idx );
		}
	}
	if( pMod != NULL && submod_idx < pMod->max_sub ){
		pSubMod = pMod->sub_mods;
		if( pSubMod[submod_idx-1].idx != submod_idx ){
			pSubMod = alertGetSubModule( pMod->sub_mods, submod_idx );
		}else{
			pSubMod = &pSubMod[submod_idx-1];
		}
	}
	if( pSubMod != NULL && code_idx < pSubMod->max_msg ){
		msg = pSubMod->msgs;
		if( msg[code_idx-1].idx != code ){
			msg = alertGetSubMessage( pSubMod->msgs, code );
		}else{
			msg = &msg[code_idx-1];
		}
	}
	if( msg == NULL ){
		if( astCodeScp > 0 ){
			CCodeScope.getFilePath( astCodeScp, szPath, OS_FULLPATH );
			printf("%s  line %ld  offset %d  line %ld  offset %d : Unknown Code: %lx \n", szPath,
					CCodeScope.getBeginLine( astCodeScp ),
					CCodeScope.getBeginLineOffset( astCodeScp ),
					CCodeScope.getEndLine( astCodeScp ),
					CCodeScope.getEndLineOffset( astCodeScp ),
					code );
		}else{
			printf("\tUnknown Code: %lx \n", code );
		}
		return COEXIT_ERROR;
	}
	if( msg ->bOutput == FALSE ){
		return COEXIT_SUCCESS;
	}
	if( msg->bNeedParam ){
		if( str_length(pszParameter ) ){
			sprintf( msgBuffer, msg->strMsg, pszParameter );
		}else{
			sprintf( msgBuffer, msg->strMsg, "(null)" );
		}
	}else{
		sprintf( msgBuffer, msg->strMsg );
	}
	if( astCodeScp > 0 ){
		CCodeScope.getFilePath( astCodeScp, szPath, OS_FULLPATH );
		printf("%s  line %ld  offset %d  line %ld  offset %d : %s\n", szPath,
				CCodeScope.getBeginLine( astCodeScp ),
				CCodeScope.getBeginLineOffset( astCodeScp ),
				CCodeScope.getEndLine( astCodeScp ),
				CCodeScope.getEndLineOffset( astCodeScp ),
				msgBuffer );
	}else{
		printf("\t%s\n", msgBuffer );
	}


	while( param != NULL ){
		printf("\t\t`%s` = `%s` \n", param->opt!=NULL?param->opt:"(null)" ,  param->param!=NULL?param->param:"(null)" );
		param = param->next;
	}
	printf("\n" );
	return Alert_ReturnLevel[msg->bLevel-1];
}

/* end of file */
